<template>
  <div>
    <el-main>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane  label="诉讼" name="proceeding">
          <el-row v-if="!seeType">
            <el-col>
              <div class="condition">
                <div class="left">
                  <el-select v-if="dateValue == '全部'" style="margin-right: 10px" v-model="sort_column" placeholder="排序"
                    clearable @change="changeAddress">
                    <el-option v-for="item in sort" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                  <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                    @change="changeAddress">
                    <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>

                  <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                    @change="dateChange"></el-input>
                </div>

                <div class="right">
                  <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                    当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                    <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
                  </div>

                  <div v-if="dateValue != '全部' && !homeType"
                    style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">审结日：</div>
                  <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                    @change="dateChange(1)">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                  <el-button type="primary" @click="exportList">导出</el-button>
                </div>
              </div>

            </el-col>
            <el-col class="b_table" v-if="tableData">
              <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="tableData" style="width: 100%">
                <el-table-column prop="plo" label="原告或上诉人" align="center">
                </el-table-column>
                <el-table-column prop="deo" label="被告或被上诉人" align="center">
                </el-table-column>
                <el-table-column prop="ctio" label="标题原文" align="center">
                </el-table-column>
                <el-table-column prop="cdn" label="案号" align="center">
                </el-table-column>
                <el-table-column prop="cn" label="法院名称" align="center">
                </el-table-column>
                <el-table-column prop="ct" label="案件类型" align="center">
                </el-table-column>
                <el-table-column prop="cjd" label="审结日" align="center">
                  <template slot-scope="scope">
                    {{ scope.row.cjd | time }}
                  </template>
                </el-table-column>
                <el-table-column prop="ja" label="判决金额" align="center">
                  <template slot-scope="scope">
                    {{ Number(scope.row.ja) }}
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center">
                  <template slot-scope="scope">
                    <div class="operate">
                      <div @click="see(scope.row.cid)">查看</div>
                      <div @click="download(scope.row.cid)">下载</div>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
          <el-row v-else>
            <el-col>
              <el-button size="mini" style="margin-bottom: 20px" @click="back">返回</el-button>
              <div v-html="html"></div>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane  label="新授权" name="authorization">
          <div class="condition">
            <div class="left">
              <el-select v-if="dateValue == '全部'" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

              <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                @change="dateChange"></el-input>
            </div>

            <div class="right">
              <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
              </div>

              <div v-if="dateValue != '全部' && !homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                公告(公开)日：</div>
              <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                @change="dateChange(1)">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportList">导出</el-button>
            </div>
          </div>


          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" @row-click="rowClick"
              style="width: 100%">

              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="tio" label="专利标题" align="center">
              </el-table-column>
              <el-table-column prop="lsscn" label="当前权利状态" align="center">
              </el-table-column>
              <el-table-column prop="pdt" label="专利类型" align="center">
              </el-table-column>
              <el-table-column prop="apo" label="当前申请(专利权)人" align="center">
              </el-table-column>
              <el-table-column prop="ino" label="发明人" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ad | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pd" label="公告(公开)日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.pd | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pns" label="公开号" align="center">
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane  label="复审" name="reexamine">
          <el-select v-model="sort_column" placeholder="排序" clearable @change="changeAddress">
            <el-option v-for="item in sortNew" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" @row-click="rowClick"
              style="width: 100%">

              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="tio" label="专利标题" align="center">
              </el-table-column>
              <el-table-column prop="lsscn" label="当前权利状态" align="center">
              </el-table-column>
              <el-table-column prop="pdt" label="专利类型" align="center">
              </el-table-column>
              <el-table-column prop="apo" label="当前申请(专利权)人" align="center">
              </el-table-column>
              <el-table-column prop="ino" label="发明人" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ad | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pd" label="公告(公开)日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.pd | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pns" label="公开号" align="center">
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane  label="转让" name="transference">
          <div class="condition">
            <div class="left">
              <el-select v-if="dateValue == '全部'" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortDI_1" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

              <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                @change="dateChange"></el-input>
            </div>

            <div class="right">
              <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
              </div>

              <div v-if="dateValue != '全部' && !homeType"
                    style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">变更生效日期：</div>
              <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                @change="dateChange(1)">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportList">导出</el-button>
            </div>
          </div>


          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" @row-click="rowClick"
              style="width: 100%">

              <el-table-column prop="tio" label="名称原文" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ad | time }}
                </template>
              </el-table-column>
              <el-table-column prop="apo" label="申请人" align="center">
              </el-table-column>
              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="pno" label="公布号" align="center">
              </el-table-column>
              <el-table-column prop="tt" label="转移类型" align="center">
                <template slot-scope="scope">
                  {{ scope.row.tt | tt }}
                </template>
              </el-table-column>
              <el-table-column prop="aasc" label="变更后权利人" align="center">
              </el-table-column>
              <el-table-column prop="edd" label="变更生效日期" align="center">
                <template slot-scope="scope">
                  {{ scope.row.edd | time }}
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane  label="质押" name="pledge">
          <div class="condition">
            <div class="left">
              <el-select v-if="dateValue == '全部'" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortDI_2" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

              <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                @change="dateChange"></el-input>
            </div>

            <div class="right">
              <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
              </div>

              <div v-if="dateValue != '全部' && !homeType"
                    style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">生效日期：</div>
              <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                @change="dateChange(1)">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportList">导出</el-button>
            </div>
          </div>


          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" style="width: 100%"
              @row-click="rowClick">

              <el-table-column prop="tio" label="名称原文" align="center">
              </el-table-column>
              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ad | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pno" label="公布号" align="center">
              </el-table-column>
              <el-table-column prop="apo" label="申请人" align="center">
              </el-table-column>
              <el-table-column prop="ppt" label="质押保全类型" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ppt | ppt }}
                </template>
              </el-table-column>
              <el-table-column prop="pprs" label="质押保全权利类型" align="center">
                <template slot-scope="scope">
                  {{ scope.row.pprs | pprs }}
                </template>
              </el-table-column>
              <el-table-column prop="ppedd" label="生效日期" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ppedd | time }}
                </template>
              </el-table-column>
              <!-- <el-table-column prop="ppdd" label="变更日期" align="center">
              </el-table-column> -->
              <el-table-column prop="pppc" label="质权人" align="center">
              </el-table-column>
              <el-table-column prop="pprdd" label="解除日期" align="center">
                <template slot-scope="scope">
                  {{ scope.row.pprdd | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pprn" label="质押登记号" align="center">
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane  label="许可" name="license">
          <div class="condition">
            <div class="left">
              <el-select v-if="dateValue == '全部'" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortDI_3" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

              <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                @change="dateChange"></el-input>
            </div>

            <div class="right">
              <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
              </div>

              <div v-if="dateValue != '全部' && !homeType"
                    style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">申请日：</div>
              <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                @change="dateChange(1)">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportList">导出</el-button>
            </div>
          </div>

          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" style="width: 100%"
              @row-click="rowClick">


              <el-table-column prop="tio" label="名称原文" align="center">
              </el-table-column>
              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center">
                <template slot-scope="scope">
                  {{ scope.row.ad | time }}
                </template>
              </el-table-column>
              <el-table-column prop="pno" label="公布号" align="center">
              </el-table-column>
              <el-table-column prop="apo" label="申请人" align="center">
              </el-table-column>
              <el-table-column prop="pt" label="专利权许可类型" align="center">
                <template slot-scope="scope">
                  {{ scope.row.pt | pt }}
                </template>
              </el-table-column>
              <el-table-column prop="crn" label="备案合同号" align="center">
              </el-table-column>
              <el-table-column prop="crdd" label="合同备案日期" align="center">
                <template slot-scope="scope">
                  {{ scope.row.crdd | time }}
                </template>
              </el-table-column>
              <el-table-column prop="trpc" label="受让人" align="center">
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
        <el-tab-pane  label="PCT" name="PCT">
          <div class="condition">
            <div class="left">
              <el-select v-if="dateValue == '全部'" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-select v-else style="margin-right: 10px" v-model="sort_column" placeholder="排序" clearable
                @change="changeAddress">
                <el-option v-for="item in sortNew_" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>

              <el-input v-if="dateValue != '全部'" v-model="keyInput" clearable placeholder="关键词检索"
                @change="dateChange('key')"></el-input>
            </div>

            <div class="right">
              <div v-if="homeType" style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">
                当前的检索时间为：{{ this.$route.query.start_time }}至{{ this.$route.query.end_time }}
                <span @click="clearTime" style="color: #409eff;margin: 0 10px;">清空</span>
              </div>

              <div v-if="dateValue != '全部' && !homeType"
                    style="display: flex;align-items: center;margin-right: 10px;cursor: pointer;">申请日：</div>
              <el-select v-if="!homeType" style="margin-right: 10px" v-model="dateValue" placeholder="请选择"
                @change="dateChange(1)">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
              <el-button type="primary" @click="exportList">导出</el-button>
            </div>
          </div>

          <div class="b_table">
            <el-table :header-cell-style="{ backgroundColor: '#f5f6f9' }" :data="patentTypeList" @row-click="rowClick"
              style="width: 100%">


              <el-table-column prop="ano" label="申请号" align="center">
              </el-table-column>
              <el-table-column prop="tio" label="专利标题" align="center">
              </el-table-column>
              <el-table-column prop="pdt" label="专利类型" align="center">
              </el-table-column>
              <el-table-column prop="apo" label="当前申请(专利权)人" align="center">
              </el-table-column>
              <el-table-column prop="ino" label="发明人" align="center">
              </el-table-column>
              <el-table-column prop="ad" label="申请日" align="center"> </el-table-column>
              <el-table-column prop="pd" label="公告(公开)日" align="center">
              </el-table-column>
              <el-table-column prop="pns" label="公开号" align="center">
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>

      <div style="margin-top: 20px">
        <el-pagination v-if="!seeType" @current-change="handleCurrentChange" :page-size="10" :current-page.sync="page"
          layout="prev, pager, next, jumper" :total="pageCount">
        </el-pagination>
      </div>
    </el-main>
  </div>
</template>

<script>
import {
  cseExpression,
  transferSearchExpression,
  expression,
  getConfig,
  permitSearchExpression,
  pledgeSearchExpression,
  detailCatalog,
  cseDownload
} from "@/api/configApi";
import {
  getLawMonth,
  getLawList
} from "@/api/newuser";
import { VUE_APP_BASE_API } from "@/config";

export default {
  components: {},
  filters: {
    ja(data) { },
    time(date) {
      if (!date) {
        return "";
      }
      let str = "";
      let arr = date.split(";");
      arr.map((res) => {
        if (!str) {
          str += res.slice(0, 10);
        } else {
          str = str + ";" + res.slice(0, 10);
        }
      });
      return str;
    },
    pt(data) {
      if (!data) {
        return "";
      }

      let str = "";
      let obj = {
        1: "普通许可",
        2: "独占许可",
        3: "排他许可",
        4: "分许可",
        5: "交叉许可",
      };
      let arr = data.split(";");
      arr.map((res) => {
        if (!str) {
          str += obj[res];
        } else {
          str = str + ";" + obj[res];
        }
      });

      return str;
    },
    pprs(data) {
      if (!data) {
        return "";
      }

      let str = "";
      let obj = {
        1: "申请权",
        2: "专利权",
      };
      let arr = data.split(";");
      arr.map((res) => {
        if (!str) {
          str += obj[res];
        } else {
          str = str + ";" + obj[res];
        }
      });

      return str;
    },
    ppt(data) {
      if (!data) {
        return "";
      }
      let str = "";
      let obj = {
        1: "质押",
        2: "保全",
      };
      let arr = data.split(";");
      arr.map((res) => {
        if (!str) {
          str += obj[res];
        } else {
          str = str + ";" + obj[res];
        }
      });

      return str;
    },
    tt(data) {
      if (!data) {
        return "";
      }
      let str = "";
      let obj = {
        1: "申请权转移",
        2: "专利权转移",
      };
      let arr = data.split(";");
      arr.map((res) => {
        if (!str) {
          str += obj[res];
        } else {
          str = str + ";" + obj[res];
        }
      });

      return str;
    },
  },
  data() {
    return {
      homeType: null,
      keyInput: '',
      options: [],
      dateValue: '全部',
      back_name: "",
      region_id: this.$store.state.user.region_id,
      seeType: false,
      patentTypeList: [],
      tableData: [],
      activeName: "proceeding",
      sort_column: "-CJD",
      html: "",
      page: 1,
      pageCount: 0,
      text: "",
      sortNew_: [
        {
          value: 1,
          label: "降序",
        },
        {
          value: 2,
          label: "升序",
        },
      ],
      sort: [
        {
          value: "-CJD",
          label: "审结日-降序",
        },
        {
          value: "+CJD",
          label: "审结日-升序",
        },
        {
          value: "-JA",
          label: "判决金额-降序",
        },
        {
          value: "+JA",
          label: "判决金额-升序",
        },
      ],
      sortNew: [
        {
          value: "-AD",
          label: "申请日-降序",
        },
        {
          value: "+AD",
          label: "申请日-升序",
        },
        {
          value: "-PD",
          label: "公布日-降序",
        },
        {
          value: "+PD",
          label: "公布日-升序",
        },
      ],
      sortDI_1: [
        {
          value: "-EDD",
          label: "变更生效日期-降序",
        },
        {
          value: "+EDD",
          label: "变更生效日期-升序",
        },
      ],
      sortDI_2: [
        {
          value: "-PPDD",
          label: "变更日期-降序",
        },
        {
          value: "+PPDD",
          label: "变更日期-升序",
        },
        {
          value: "-PPEDD",
          label: "生效日期-降序",
        },
        {
          value: "+PPEDD",
          label: "生效日期-升序",
        },
      ],
      sortDI_3: [
        {
          value: "-CRDD",
          label: "合同备案日期-降序",
        },
        {
          value: "+CRDD",
          label: "合同备案日期-升序",
        },
      ],
      companyName: "",
      name: "",
      page: 1,

      start_time: '',
      end_time: ''
    };
  },
  mounted() {
    this.homeType = this.$route.query.activeName

    this.start_time = this.$route.query.start_time ? this.$route.query.start_time.split('-').join('') : ''
    this.end_time = this.$route.query.end_time ? this.$route.query.end_time.split('-').join('') : ''



    this.getConfig();

  },
  methods: {
    exportList() {
      console.log(this.homeType);
      if (this.dateValue == '全部' || this.homeType) {
        console.log('进来');
        this.$message({
          message: '全部数据模式下无法导出，仅支持导出月份数据',
          type: 'warning'
        });
        return
      }

      let type = 6
      let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
      label.map((res, index) => {
        if (res == this.activeName) {
          type = index + 1
        }
      })
      window.open(
        `${VUE_APP_BASE_API}/v1/export/lawExcel?region_id=${this.region_id}&type=${type}&date=${this.dateValue}&sort=${this.sort_column}&keyword=${this.keyInput}`
      );
    },
    dateChange(classType) {
      if (this.dateValue != '全部') {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.page = 1;
        if (classType == 1) {
          this.sort_column = 1
          this.keyInput = ''
        }
        this.getLawList(type)
      } else {
        this.handleClick()
      }
    },
    getLawList(type) {
      getLawList({
        type: type,
        date: this.dateValue,
        page: this.page,
        limit: 10,
        keyword: this.keyInput,
        sort: this.sort_column
      }).then(res => {
        if (type == 6) {
          this.tableData = res.list;
          this.pageCount = Number(res.count);
          if (res.total >= 10000) {
            this.pageCount = 10000;
          }
        } else {
          this.patentTypeList = res.list;
          this.pageCount = Number(res.count);
          if (this.pageCount >= 10000) {
            this.pageCount = 10000;
          }
        }

      })
    },
    getLawMonth(type, start) {
      getLawMonth({
        type: type
      }).then(res => {
        this.options = res.list
        this.options.unshift({
          label: "全部",
          value: "全部",
        })

        if (start && !this.homeType) {
          this.dateValue = this.options[1].value
          this.dateChange(1)
        }


        if (this.homeType) {
          // this.dateValue = this.options[this.options.length - 1].value
          let obj = [
            {
              id: 1,
              name: 'authorization'
            },
            {
              id: 2,
              name: 'transference'
            },
            {
              id: 3,
              name: 'pledge'
            },
            {
              id: 4,
              name: 'PCT'
            },
            {
              id: 5,
              name: 'license'
            },
            {
              id: 6,
              name: 'proceeding'
            },
          ]
          obj.map(res => {
            if (this.homeType == res.id) {
              this.activeName = res.name
            }
          })
          this.handleClick()
          ////江鑫
          // this.dateChange(1)
        }


      })
    },
    getConfig() {
      getConfig({
        region_id: this.region_id,
      }).then((res) => {
        this.back_name = res.list.back_name;

        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawMonth(type, 1)

        // if (!this.homeType) {
        //   this.text = `相关人,文本+=('${this.back_name}')`;
        //   this.cseExpression();
        // }
      });
    },
    cseExpression() { //诉讼

      if (this.dateValue == '全部') {

        cseExpression({
          express: this.text,
          page: this.page,
          page_row: 10,
          sort_column: this.sort_column,
        }).then((res) => {
          if (res.list) {
            this.tableData = res.list;
            this.pageCount = Number(res.total);
            if (res.total >= 10000) {
              this.pageCount = 10000;
            }
          } else {
            this.tableData = [];
            this.pageCount = 0;
          }
        });
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawList(type)
      }

    },
    rowClick(row, column, event) {
      //新窗口打开
      const { href } = this.$router.resolve({
        path: "/detail",
      });
      window.open(href + `?pid=${row.pid}&preview=1`, "_blank");
    },
    clearTime() {
      this.homeType = null

      let type = 6
      let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
      label.map((res, index) => {
        if (res == this.activeName) {
          type = index + 1
        }
      })
      this.getLawMonth(type)
      this.handleClick();
    },
    handleClick(tab, event) {
      this.seeType = false;
      this.page = 1;
      // if (tab) {
      //   this.dateValue = '全部'
      //   this.sort_column = 1
      // }activeName
      // debugger
      if (tab && tab.label != '复审') {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.homeType = null
        this.getLawMonth(type, 1)
        return
      }



      let time = ''

      if (this.homeType) {
        time = ` AND (PD>= ${this.start_time} AND PD<${this.end_time})`
      }
      if (this.activeName == "proceeding") {
        this.sort_column = "-CJD";
        this.text = `相关人,文本+=('${this.back_name}')` + time;
        this.cseExpression();
      } else if (this.activeName == "authorization") {
        this.sort_column = "-AD";
        this.text = `申请人地址=${this.back_name}` + time + ' AND LSSC=1';
        this.expression(this.text);
      } else if (this.activeName == "reexamine") {
        this.sort_column = "-AD";
        this.text = `申请人地址=${this.back_name} AND (复审决定=是)` + time;
        this.expression(this.text);
      } else if (this.activeName == "transference") {
        this.sort_column = "-EDD";
        this.text = `申请人地址=${this.back_name}` + time;
        this.transferSearchExpression();
      } else if (this.activeName == "pledge") {
        this.sort_column = "-PPDD";
        this.text = `申请人地址=${this.back_name}` + time;
        this.DiPledge();
      } else if (this.activeName == "license") {
        this.sort_column = "-CRDD";
        this.text = `申请人地址=${this.back_name}` + time;
        this.DiPermit();
      } else if (this.activeName == "PCT") {
        this.sort_column = "-AD";
        this.text = `申请人地址=${this.back_name} AND (PCT=是)` + time;
        this.expression(this.text);
      }
    },
    DiPermit() {
      if (this.dateValue == '全部') {
        permitSearchExpression({
          express: this.text,
          page: this.page,
          page_row: 10,
          sort_column: this.sort_column,
        }).then((res) => {
          this.patentTypeList = res.list;
          this.pageCount = Number(res.total);
          if (this.pageCount >= 10000) {
            this.pageCount = 10000;
          }
        });
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawList(type)
      }

    },
    DiPledge() {
      if (this.dateValue == '全部') {
        pledgeSearchExpression({
          express: this.text,
          page: this.page,
          page_row: 10,
          sort_column: this.sort_column,
        }).then((res) => {
          this.patentTypeList = res.list;
          this.pageCount = Number(res.total);
          if (this.pageCount >= 10000) {
            this.pageCount = 10000;
          }
        });
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawList(type)
      }

    },
    transferSearchExpression() { //转让
      if (this.dateValue == '全部') {

        transferSearchExpression({
          express: this.text,
          page: this.page,
          sort_column: this.sort_column,
          page_row: 10,
        }).then((res) => {
          this.patentTypeList = res.list;
          this.pageCount = Number(res.total);
          if (this.pageCount >= 10000) {
            this.pageCount = 10000;
          }
        });
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawList(type)
      }

    },
    back() {
      this.html = "";
      this.seeType = false;
    },
    handleCurrentChange(val) {
      this.page = val;
      console.log(this.text, 'text');
      console.log(this.activeName, 'activeName');
      if (this.activeName == "proceeding") {
        this.cseExpression();
        // this.expression(this.text);
      } else if (this.activeName == "transference") {
        this.transferSearchExpression();
      } else if (this.activeName == "pledge") {
        this.DiPledge();
      } else if (this.activeName == "license") {
        this.DiPermit();
      } else {
        this.expression(this.text);
      }
    },
    changeAddress(value) {
      this.sort_column = value;
      this.page = 1;
      if (this.dateValue == '全部') {
        if (this.activeName == "proceeding") {
          this.cseExpression();
        } else if (this.activeName == "transference") {
          this.transferSearchExpression();
        } else if (this.activeName == "pledge") {
          this.DiPledge();
        } else if (this.activeName == "license") {
          this.DiPermit();
        } else {
          this.expression(this.text);
        }
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.page = 1;
        this.getLawList(type)
      }
    },
    see(id) {
      detailCatalog({
        id: id,
      }).then((res) => {
        this.seeType = true;
        this.html = res.list[0].referee.cfto;
      });
    },
    download(id) {
      cseDownload({
        id: id,
      }).then((res) => {
        window.open(res.list[0].pdfPath);
      });
    },
    expression(exp) { //新授权、复审
      if (this.dateValue == '全部') {
        expression({
          express: exp,
          page: this.page,
          page_row: 10,
          exactSearch: 1,
          sort_column: this.sort_column,
        }).then((res) => {
          this.patentTypeList = res.list;
          this.pageCount = Number(res.total);
          if (this.pageCount >= 10000) {
            this.pageCount = 10000;
          }
        });
      } else {
        let type = 6
        let label = ["authorization", "transference", "pledge", "PCT", "license", "proceeding"]
        label.map((res, index) => {
          if (res == this.activeName) {
            type = index + 1
          }
        })
        this.getLawList(type)
      }

    },
  },
};
</script>

<style scoped lang="less">
.el-main {
  margin: 25px 30px 0 30px;
  border-radius: 5px;
}

.operate {
  display: flex;
  justify-content: space-around;
}

.b_table {
  margin-top: 20px;
}

.el-icon-search {}

.condition {
  display: flex;
  justify-content: space-between;

  .left {
    display: flex;

  }

  .right {
    display: flex;

  }
}

@media (max-width: 1360px) {}

@media (max-width: 1280px) {}
</style>
